/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jpaintball;

import java.awt.geom.Area;

/**
 *
 * @author ondra
 */
public abstract class MovableGameObject extends GameObject {

    protected Position savedPosition;
    protected GameObject collisionObject;

    protected double frametime;
    protected double speedX;
    protected double speedY;

    MovableGameObject(int x, int y, int width, int height, int poleX, int poleY, double angle, double _frametime) {
        super(x, y, width, height, poleX, poleY, angle);
        frametime = _frametime;
        speedX = 0;
        speedY = 0;
    }

    abstract public void move();

    protected void savePosition() {
        savedPosition = new Position(position);
    }
    protected void restorePosition() {
        if(savedPosition != null) {
            position = new Position(savedPosition);
        }
    }
    public void setCollisionWith(GameObject o){
        collisionObject = o;
    }
    public boolean collidesWith(GameObject o) {
        
        if(o == null) return false;

        Area tempArea = new Area(getArea());
        tempArea.intersect(o.getArea());
        if(tempArea.isEmpty()){
            return false;
        }
        return true;
    }
}
